//
//  DSLoadingViewController.m
//  iOSUIFrame
//
//  Created by song duan on 12-6-8.
//  Copyright (c) 2012年 adways. All rights reserved.
//

#import "DSLoadingViewController.h"
#import "AppDelegate.h"

@implementation DSLoadingViewController

#pragma mark - View lifecycle methods

- (void)viewDidLoad
{
    UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)];
    bgImageView.backgroundColor = [UIColor clearColor];
    bgImageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]];
    [self.view addSubview:bgImageView];
    [bgImageView release];
    
    _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150, 400, 20, 20)];
    _activityIndicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
    _activityIndicatorView.hidesWhenStopped = YES;
    [_activityIndicatorView startAnimating];
    [self.view addSubview:_activityIndicatorView];
    [_activityIndicatorView release];
    
    [self performSelector:@selector(loadingDone) withObject:nil afterDelay:3];    // 假设加载3秒中
    
    [super viewDidLoad];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (void)loadingDone
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
    [(AppDelegate *)[UIApplication sharedApplication].delegate loadMainView];
    [_activityIndicatorView stopAnimating];
}

#pragma mark - Memory management methods

- (void)dealloc
{
    [super dealloc];
}

@end
